/**
* 版权声明：厦门睿商网络科技有限公司 版权所有 违者必究
* 日    期：2020-07-09
*/
package com.rzico.market.entity;

import com.alibaba.fastjson.JSON;
import com.rzico.basics.model.ProductArticle;
import com.rzico.basics.model.ProductMeta;
import lombok.Data;
import java.util.Date;
import javax.persistence.*;
import io.swagger.annotations.ApiModelProperty;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;

/**
 * <pre>
 *   第三方产品档案数据库对象
 * </pre>
 * @author Rzico Boot
 * @version 1.0
 */
@Data
@JsonIgnoreProperties(value = {"handler"})
@JsonInclude(JsonInclude.Include.NON_NULL)
@Table(name = "mk_market_product")
public class MarketProduct{
    @Id
    @ApiModelProperty(value = "" )
    protected Long id;

    @ApiModelProperty(value = "创建日期" )
    protected java.util.Date createDate;

    @ApiModelProperty(value = "修改日期" )
    protected java.util.Date modifyDate;

    @ApiModelProperty(value = "是否列出" )
    protected Boolean isList;

    @ApiModelProperty(value = "是否上架")
    protected Boolean isMarketable;

    @ApiModelProperty(value = "是否可售")
    protected Boolean saleState;

    @ApiModelProperty(value = "是否已上架至商品库")
    protected Boolean isShelf;

    @ApiModelProperty(value = "市场价" )
    protected java.math.BigDecimal marketPrice;

    @ApiModelProperty(value = "名称" )
    protected String name;

    @ApiModelProperty(value = "描述说明" )
    protected String subTitle;

    @ApiModelProperty(value = "销售价" )
    protected java.math.BigDecimal price;

    @ApiModelProperty(value = "结算价" )
    protected java.math.BigDecimal cost;

    @ApiModelProperty(value = "税率" )
    protected java.math.BigDecimal tax;

    @ApiModelProperty(value = "sku编号/条码" )
    protected String sn;

    @ApiModelProperty(value = "单位" )
    protected String unit;

    @ApiModelProperty(value = "单位系数" )
    protected java.math.BigDecimal unitRate;

    @ApiModelProperty(value = "重量" )
    protected java.math.BigDecimal weight;

    @ApiModelProperty(value = "商品分组编号" )
    protected String goodId;

    @ApiModelProperty(value = "市场分类" )
    protected Long marketCategory;

    @ApiModelProperty(value = "规格" )
    protected String spec1;

    @ApiModelProperty(value = "颜色" )
    protected String spec2;

    @ApiModelProperty(value = "缩略图" )
    protected String thumbnail;

    @ApiModelProperty(value = "商品类型 {0:实物,1:虚拟}" )
    protected Integer type;

    @ApiModelProperty(value = "保期质" )
    protected Integer quality;

    @ApiModelProperty(value = "其他资源({video:视频url,images:[图片url},label:标签属性)" )
    protected String meta;

    @ApiModelProperty(value = "商品详情" )
    protected String content;

    @ApiModelProperty(value = "商品详情图" )
    protected String wxintroduction;

    @ApiModelProperty(value = "商品图片" )
    protected String image;

    @ApiModelProperty(value = "品牌" )
    protected String brandName;

    @ApiModelProperty(value = "供应商" )
    protected Long supplierId;

    @ApiModelProperty(value = "京东过来的sku_id" )
    protected String skuId;

    @ApiModelProperty(value = "市场插件id" )
    protected String marketPluginId;

    @ApiModelProperty(value = "来源商户" )
    protected Long enterpriseId;

    @JsonIgnore
    @ApiModelProperty(value = "创建者" ,hidden = true )
    protected String createBy;

    @JsonIgnore
    @ApiModelProperty(value = "更新者" ,hidden = true )
    protected String modifyBy;

    @JsonIgnore
    public ProductArticle getMetaAndContent() {
        ProductArticle article = new ProductArticle();
        article.setContent(getContent());
        if (getMeta()!=null) {
            article.setProductMeta(JSON.parseObject(getMeta(), ProductMeta.class));
        } else {
            article.setProductMeta(new ProductMeta());
        }
        return article;
    }

}
